cmake_minimum_required(VERSION 3.20)
project(asycipc LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_library(asycipc
    include/asycipc/api.hpp
    include/asycipc/crc32c.hpp
    include/asycipc/frame.hpp
    include/asycipc/handshake.hpp
    include/asycipc/inmemory_transport.hpp
    include/asycipc/linux_diagnostics.hpp
    include/asycipc/session_context.hpp
    include/asycipc/transport.hpp
    include/asycipc/named_pipe.hpp
    include/asycipc/backpressure.hpp
    include/asycipc/config_service.hpp
    include/asycipc/heartbeat.hpp
    include/asycipc/sliding_window.hpp
    include/asycipc/telemetry.hpp
    include/asycipc/server_runtime.hpp
    src/api.cpp
    src/backpressure.cpp
    src/config_service.cpp
    src/crc32c.cpp
    src/frame.cpp
    src/handshake.cpp
    src/heartbeat.cpp
    src/inmemory_transport.cpp
    src/session_context.cpp
    src/sliding_window.cpp
    src/telemetry.cpp
    src/linux_diagnostics.cpp
    src/linux_pipe.cpp
    src/macos_pipe.cpp
    src/windows_pipe.cpp
    src/server_runtime.cpp
    thirdparty/json11/json11.cpp)

target_include_directories(asycipc
  PUBLIC include
  PRIVATE thirdparty/json11)

if(MSVC)
  target_compile_options(asycipc PRIVATE /W4 /permissive-)
else()
  target_compile_options(asycipc PRIVATE -Wall -Wextra -Wpedantic)
endif()

if(WIN32)
  target_compile_definitions(asycipc PRIVATE WIN32_LEAN_AND_MEAN)
endif()

add_subdirectory(thirdparty/gtest EXCLUDE_FROM_ALL)

enable_testing()

add_executable(winpipe_stress
    tools/winpipe_stress.cpp)

target_link_libraries(winpipe_stress PRIVATE asycipc)
target_include_directories(winpipe_stress PRIVATE include)

add_executable(asycipc_demo_server
    tools/demo_server.cpp)
target_link_libraries(asycipc_demo_server PRIVATE asycipc)
target_include_directories(asycipc_demo_server PRIVATE include)

add_executable(asycipc_demo_client
    tools/demo_client.cpp)
target_link_libraries(asycipc_demo_client PRIVATE asycipc)
target_include_directories(asycipc_demo_client PRIVATE include)

add_executable(asycipcctl
    tools/asycipcctl.cpp)
target_include_directories(asycipcctl PRIVATE include thirdparty/json11)
target_link_libraries(asycipcctl PRIVATE asycipc)

add_executable(asycipc_plan01_tests
    test/asycipc_plan01_test.cc
    test/linux_fifo_diagnostics_test.cc)

target_link_libraries(asycipc_plan01_tests PRIVATE asycipc gtest_main)

target_include_directories(asycipc_plan01_tests PRIVATE
    thirdparty/gtest/googletest/include
    thirdparty/gtest/googlemock/include
    include
    thirdparty/json11)

add_test(NAME plan01 COMMAND asycipc_plan01_tests)





